package Class.Homemade.demo0525.demo4;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 姚东名
 * Date: 2024-05-25
 * Time: 22:27
 */
public class Duck extends Animal implements IFly, ISwimming{
    //1.首先，子类继承父类，就得调用子列的构造方法来对父类的成员初始化
    public Duck(String name, int age) {
        super(name, age);
    }
    //其次，父类是抽象类，就需要对抽象方法进行重写
    @Override
    public void eat() {
        System.out.println(this.name + "正在吃鸭粮！");
    }
    //最后，因为用关键字implements,把Duck类与接口连接起来了，接口比抽象类还抽象，需对接口中的抽象方法进行重写
    @Override
    public void fly() {
        System.out.println(this.name + "正在飞！");
    }

    @Override
    public void swim() {
        System.out.println(this.name + "正在游泳！");
    }
}
